package com.frame.pageform.tag;

import com.frame.pageform.*;
import com.frame.util.DataConvert;

public class TextAreaTag extends BaseHandlerTag{

	private String bind;
	private String name;
	private String value;
	private String readonly;
	private String onclick;
	private String type;
	private String dataOptions;

	public int start() throws Exception
	{
		String text=(name==null?bind:name);
		String s="<textarea name=\""+text+"\"";
		onclick=null;
		if(value==null)
			value="";
		if("null".equals(value))
			value="";
		else if("".equals(value)){
			if(getContext()!=null){
				Object obj=executeExpression(bind);
//				Class c=new PageBeanUtil().getPropertyType(bind, getContext().getPageForm().getClass());
//				if(c==java.util.Date.class || c==java.sql.Date.class){
//					if(onclick==null)
//						onclick="date(this)";
//				}
				value=DataConvert.toString(obj);
				value=ResponseUtils.filter(value);
			}
		}
		if(type!=null)
			s+=" type=\""+type+"\"";
		if(readonly!=null)
			s+=" readonly=\""+readonly+"\"";

		if(onclick!=null)
			s+=" onclick=\""+onclick+"\"";
		if(dataOptions!=null)
			s+=" data-options=\""+dataOptions+"\"";
		StringBuffer sb = new StringBuffer();
		prepareHandler(sb);
		s+=sb.toString()+">";
		s+=value;
		s+="</textarea>";
		value=null;
		write(s);

		return 0;
	}


	public String getBind() {
		return bind;
	}


	public void setBind(String bind) {
		this.bind = bind;
	}


	public String getValue() {
		return value;
	}
	public void setValue(String value) {
		this.value = value;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}
	public String getReadonly() {
		return readonly;
	}

	public void setReadonly(String readonly) {
		this.readonly = readonly;
	}

	public String getOnclick() {
		return onclick;
	}

	public void setOnclick(String onclick) {
		this.onclick = onclick;
	}

	public String getType() {
		return type;
	}


	public void setType(String type) {
		this.type = type;
	}


	public String getDataOptions() {
		return dataOptions;
	}


	public void setDataOptions(String dataOptions) {
		this.dataOptions = dataOptions;
	}


	public String getName() {
		return name;
	}


	public void setName(String name) {
		this.name = name;
	}

}
